





ALTER      proc sp_update_inventory_lot_for_finished_goods (

@date_in varchar (20),
@date_out varchar (20),
@qty_in varchar (20),
@qty_out varchar (20),
@lot_no varchar (20),
@lot_id varchar (20))



as
begin
select * from lot_table
	if @date_in = '01/01/1900' 
	begin
		set @date_in = null
	end

	if @date_out = null
	begin
		set @date_out = null
	end	

	if @qty_in = null
	begin
		set @qty_in = null
	end

	if @qty_out = null
	begin
		set @qty_out = null
	end	


	declare @temp_lot_no varchar(20)
	declare @temp_location_id int
	select @temp_lot_no= Lot_Number, @temp_location_id=Location_ID from Lot_Table where Lot_ID = @lot_id
	if @temp_lot_no <> @lot_no
		begin
			update Lot_Table set Lot_Number = @lot_no where Lot_ID = @lot_id and Location_ID = @temp_location_id
		end
	
	declare @temp_lot_id int
	select 	@temp_lot_id=Lot_ID from inventory_lot where Lot_ID = @lot_id 
	if @temp_lot_id is not null 
		--check if no present
		begin
			update inventory_lot set IL_Date_In = @date_in, IL_Qty_In = @qty_In, IL_Date_Out = @date_out, IL_Qty_Out=@qty_out where Lot_ID = @lot_id
		end
	else
		
		return
		

end





